/*
 * @Author: haungyan
 * @Date: 2020-11-24 23:24:59
 * @LastEditors: haungyan
 * @LastEditTime: 2020-11-24 23:28:27
 * @Description: file content
 * @FilePath: \mini-vue\js\dep.js
 */
class Dep {
    constructor() {
        // 观察者队列
        this.subs = []
    }

    // 添加观察者
    addSub(sub) {
        if (sub && sub.update) {
            this.subs.push(sub)
        }
    }

    // 发送通知
    notify() {
        this.subs.forEach(sub => {
            sub.update()
        })
    }
}